package com.open.basic.enums;


import com.open.basic.constant.SystemConst;

/**
 * @author system
 * @Date 2023/12/3 14:16
 * @description 操作枚举
 */
public enum OperationEnum {
    /**
     * 查看
     */
    VIEW(SystemConst.OPERATION_VIEW, "查看"),

    /**
     * 添加
     */
    ADD(SystemConst.OPERATION_ADD, "添加"),
    /**
     * 更新
     */
    UPDATE(SystemConst.OPERATION_UPDATE, "更新"),
    /**
     * 删除
     */
    DELETE(SystemConst.OPERATION_DELETE, "删除"),
    /**
     * 查询
     */
    QUERY(SystemConst.OPERATION_QUERY, "查询"),

    /**
     * 上传
     */
    UPLOAD(SystemConst.OPERATION_UPLOAD, "上传"),

    /**
     * 下载
     */
    DOWNLOAD(SystemConst.OPERATION_DOWNLOAD, "下载"),

    /**
     * 导出
     */
    EXPORT(SystemConst.OPERATION_EXPORT, "导出"),

    /**
     * 导入
     */
    IMPORT(SystemConst.OPERATION_IMPORT, "导入"),

    /**
     * 登录
     */
    LOGIN(SystemConst.OPERATION_LOGIN, "登录"),

    /**
     * 退出
     */
    LOGOUT(SystemConst.OPERATION_LOGOUT, "退出"),

    /**
     * 注册
     */
    REGISTER(SystemConst.OPERATION_REGISTER, "注册"),

    /**
     * 忘记密码
     */
    FORGET_PASSWORD(SystemConst.FORGET_PASSWORD, "忘记密码"),

    /**
     * 修改密码
     */
    CHANGE_PASSWORD(SystemConst.CHANGE_PASSWORD, "修改密码");


    private String value;
    private String desc;

    OperationEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static OperationEnum getEnum(String value) {
        for (OperationEnum operationEnum : OperationEnum.values()) {
            if (operationEnum.getValue().equals(value)) {
                return operationEnum;
            }
        }
        return null;
    }

    public static String getDesc(String value) {
        if (value == null) {
            return null;
        }
        for (OperationEnum operationEnum : OperationEnum.values()) {
            if (operationEnum.getValue().equals(value)) {
                return operationEnum.getDesc();
            }
        }
        return null;
    }
}
